package com.uzhie.web.service;

import com.uzhie.web.bean.PageBean;
import com.uzhie.web.dao.GpsDAO;
import com.uzhie.exception.GPSException;
import com.uzhie.web.module.GpsRecord;
import org.apache.ibatis.session.RowBounds;
import org.apache.log4j.Logger;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * 定位信息基础表
 * Created by lilongfei on 2018/8/1.
 */
@Service
public class GpsService {

    private Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private GpsDAO dao;

    /**
     * 通过sim卡获取定位信息
     *
     * @param simNum
     * @return
     */
    public GpsRecord queryListBySIM(@NotEmpty(message = GPSException.Status.SIM_ERROR) String simNum) {
        return dao.queryListBySIM(simNum);
    }


    /**
     * 通过sim卡列表获取定位信息列表
     *
     * @param simNumbers
     * @return
     */
    public List<GpsRecord> queryListBySimList(@NotNull(message = GPSException.Status.SIM_ERROR) List<String> simNumbers) {
        List<GpsRecord> result = new ArrayList<>();
        for (String sim : simNumbers) {
            GpsRecord gpsRecord = dao.queryListBySIM(sim);
            if (gpsRecord != null) result.add(gpsRecord);
        }
        return result;
    }

    public  List<GpsRecord> queryDayTrajectoryByVehicleNumber(@NotNull(message = "车牌号不能为空！") String vehicleNumber,@NotNull(message = "日期不能为空！") String day){
        return dao.queryDayTrajectoryByVehicleNumber(vehicleNumber,day);
    }
}
